package com.itheima.accountingdb.mapper;

import com.itheima.accountingdb.pojo.Category;
import com.itheima.accountingdb.pojo.PageBean;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author panweiwei
 */
@Mapper
public interface CategoryMapper {
    /**
     * 添加分类
     *
     * @param category
     * @return
     */
    @Insert("insert into category(user_id,name,type,is_Deleted) values(#{userId},#{name},#{type},0)")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int add(Category category);

    /**
     * 更新分类
     *
     * @param id
     * @param category
     * @return
     */
    int update(Category category);

    /**
     * 删除分类
     *
     * @param id
     * @return
     */
    @Update("update category set is_deleted = 1 where id = #{id}")
    int delete(Long id);


    /**
     * 查询分类
     *
     * @param page
     * @param size
     * @param name
     * @param type
     * @param isDeleted
     * @return
     */
    List<Category> list(Integer page, Integer size, String name, String type, Long isDeleted, Long userId);
}